package com.hm.manage.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hm.common.annotation.Log;
import com.hm.common.core.controller.BaseController;
import com.hm.common.core.domain.AjaxResult;
import com.hm.common.enums.BusinessType;
import com.hm.manage.domain.Xtxj;
import com.hm.manage.service.IXtxjService;
import com.hm.common.utils.poi.ExcelUtil;
import com.hm.common.core.page.TableDataInfo;

/**
 * 系统巡检Controller
 * 
 * @author hm
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/manage/xtxj")
public class XtxjController extends BaseController
{
    @Autowired
    private IXtxjService xtxjService;

    /**
     * 查询系统巡检列表
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:list')")
    @GetMapping("/list")
    public TableDataInfo list(Xtxj xtxj)
    {
        startPage();
        List<Xtxj> list = xtxjService.selectXtxjList(xtxj);
        return getDataTable(list);
    }

    /**
     * 导出系统巡检列表
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:export')")
    @Log(title = "系统巡检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xtxj xtxj)
    {
        List<Xtxj> list = xtxjService.selectXtxjList(xtxj);
        ExcelUtil<Xtxj> util = new ExcelUtil<Xtxj>(Xtxj.class);
        util.exportExcel(response, list, "系统巡检数据");
    }

    /**
     * 获取系统巡检详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xtxjService.selectXtxjById(id));
    }

    /**
     * 新增系统巡检
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:add')")
    @Log(title = "系统巡检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xtxj xtxj)
    {
        return toAjax(xtxjService.insertXtxj(xtxj));
    }

    /**
     * 修改系统巡检
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:edit')")
    @Log(title = "系统巡检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xtxj xtxj)
    {
        return toAjax(xtxjService.updateXtxj(xtxj));
    }

    /**
     * 删除系统巡检
     */
    @PreAuthorize("@ss.hasPermi('manage:xtxj:remove')")
    @Log(title = "系统巡检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xtxjService.deleteXtxjByIds(ids));
    }
}
